<html>
<head><meta charset="utf-8"><title>Question About Architecture · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Question.20About.20Architecture.html">Question About Architecture</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="226466167"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Question%20About%20Architecture/near/226466167" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vikash Balasubramanian <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Question.20About.20Architecture.html#226466167">(Feb 16 2021 at 03:03)</a>:</h4>
<p>Hello everyone, I have been recently getting into parsers and I was going through the architecture and documentation of rust analyzer.</p>
<p>It seems like a lot of the moving parts of rust-analyzer are implemented from scratch. May I know what motivated this? Why not use a parser generator framework like LALRPOP (<a href="https://crates.io/crates/lalrpop">https://crates.io/crates/lalrpop</a>) ? I have been thinking about implementing a language server for Python in Rust, and any tips would be helpful.</p>



<a name="226481070"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Question%20About%20Architecture/near/226481070" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Question.20About.20Architecture.html#226481070">(Feb 16 2021 at 07:38)</a>:</h4>
<p>See <a href="https://rust-analyzer.github.io/blog/2020/09/16/challeging-LR-parsing.html">https://rust-analyzer.github.io/blog/2020/09/16/challeging-LR-parsing.html</a></p>



<a name="226485658"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Question%20About%20Architecture/near/226485658" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Question.20About.20Architecture.html#226485658">(Feb 16 2021 at 08:39)</a>:</h4>
<p>Python has a <a href="https://en.wikipedia.org/wiki/Parsing_expression_grammar">PEG</a> grammar, which is similar to a CFG grammar except that in case of ambiguity the first matching rule applies. This means that it may not be possible to parse Python using the LALR algorithm. Instead you have to use something like Packrat or Pika parsing.</p>



<a name="226602727"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Question%20About%20Architecture/near/226602727" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vikash Balasubramanian <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Question.20About.20Architecture.html#226602727">(Feb 17 2021 at 01:25)</a>:</h4>
<p><span class="user-mention" data-user-id="133247">@bjorn3</span> That's actually pretty surprising to me. It seems like RustPython (<a href="https://github.com/RustPython/RustPython/tree/master/parser">https://github.com/RustPython/RustPython/tree/master/parser</a>) is using LALRPOP. I will ask the author if they had any issues. Obviously RustPython didn't really focus on error resilience, so it may not apply anyways.</p>



<a name="226602921"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Question%20About%20Architecture/near/226602921" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vikash Balasubramanian <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Question.20About.20Architecture.html#226602921">(Feb 17 2021 at 01:28)</a>:</h4>
<p><span class="user-mention" data-user-id="133169">@matklad</span>  Thanks that was a really well written blog post. I also did some more reading and the Rowan framework for RA seems to be pretty good. Although I wonder how general it really is. It has been designed with RA in mind. Do you think it might have any limitations when it comes to Python parsing ?</p>



<a name="226618812"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Question%20About%20Architecture/near/226618812" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Question.20About.20Architecture.html#226618812">(Feb 17 2021 at 06:34)</a>:</h4>
<p>According to <a href="https://www.python.org/dev/peps/pep-0617/">https://www.python.org/dev/peps/pep-0617/</a> python used a grammar that is almost LL(1), but not completely. That PEP describes the steps to migrate to a new PEG based grammar.</p>



<a name="226618848"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Question%20About%20Architecture/near/226618848" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Question.20About.20Architecture.html#226618848">(Feb 17 2021 at 06:35)</a>:</h4>
<p>Guido van Rossum has written a series about PEG grammars: <a href="https://medium.com/@gvanrossum_83706/peg-parsing-series-de5d41b2ed60">https://medium.com/@gvanrossum_83706/peg-parsing-series-de5d41b2ed60</a></p>



<a name="227095145"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Question%20About%20Architecture/near/227095145" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Chetan Khilosiya <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Question.20About.20Architecture.html#227095145">(Feb 20 2021 at 14:34)</a>:</h4>
<p>Hello everyone. Good morning. I am new to the rust analyzer project. I would like to contribute in this project. I am looking at the issue <a href="https://github.com/rust-analyzer/rust-analyzer/issues/7454">https://github.com/rust-analyzer/rust-analyzer/issues/7454</a>. Where can I discuss beginner level stuff about task (which topic)? I can't find the relevant topic.</p>



<a name="227095185"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Question%20About%20Architecture/near/227095185" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Question.20About.20Architecture.html#227095185">(Feb 20 2021 at 14:35)</a>:</h4>
<p>you can just create a new topic for your question (by entering a new topic name)</p>



<a name="227095339"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Question%20About%20Architecture/near/227095339" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Chetan Khilosiya <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Question.20About.20Architecture.html#227095339">(Feb 20 2021 at 14:38)</a>:</h4>
<p>ok. Thank you <span class="user-mention" data-user-id="129457">@Florian Diebold</span></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>